package yja.gzw.app.fragmentview

import android.util.Log
import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import yja.gzw.app.R
import yja.gzw.app.adapter.PingjiaAdapter
import yja.gzw.app.adapter.TuijianAdapter
import yja.gzw.app.base.BaseFragment
import yja.gzw.app.databinding.FragmentPingjiaBinding
import yja.gzw.app.model.UserData
import yja.gzw.app.viewmodel.Mainviewmodel

class PingjiaFragment :BaseFragment<Mainviewmodel, FragmentPingjiaBinding>(R.layout.fragment_pingjia){
    private lateinit var listadapter2: PingjiaAdapter

    override fun initView() {
        viewmodel.onpingjialeibiaowang(UserData.token, mapOf("user_id" to UserData.idsss))
    }

    override fun dataObservese() {
        viewmodel.onpingjialeibiao.observe(this, Observer {
            if(it.code==1){

                binding.review.layoutManager=
                    LinearLayoutManager(context, LinearLayoutManager.VERTICAL,false)
                listadapter2= PingjiaAdapter(requireContext(),it.data.data)
                binding.review.adapter= listadapter2




            }else{
                Toast.makeText(context,it.msg, Toast.LENGTH_SHORT).show()
            }

        })


    }
}